package com.maxcion.scalelayoutmanager

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import com.maxcion.scalelayoutmanager.adapter.BaseViewHolder
import com.maxcion.scalelayoutmanager.form.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val titleList =( 0..4).toList().map { TopTitle("Title--$it") }
        val students = (0..20).toList().map { Student("$it") }
        setContentView(R.layout.activity_main)
        findViewById<RecyclerView>(R.id.rv).apply {
            FormLayoutManager.Builder<Student>()
                .setMaxColumnCount(titleList.size)
                .setRecyclerView(this)
                .setContentLines(students.toMutableList())
                .setHorizontalTitles(titleList.toMutableList())
                .setContentLayoutId(R.layout.content_item)
                .setHorizontalTitleLayoutId(R.layout.title_item)
                .setContentConvert(object : ItemViewConvert<Student> {
                    override fun convertVerticalTitle(
                        bean: IVerticalTitleItem,
                        holder: BaseViewHolder
                    ) {
                    }

                    override fun convertHorizontalTitle(
                        bean: IHorizontalTitleItem,
                        holder: BaseViewHolder
                    ) {
                       holder.setText(R.id.tv, bean.getContent())
                    }

                    override fun convertContent(
                        bean: Student,
                        holder: BaseViewHolder,
                        realColumnIndex: Int
                    ) {
                        holder.setText(R.id.tv, "  ${bean.msg}  $realColumnIndex")
                    }

                })
                .create()
        }
        
        (0..20).toList()


    }
}